package com.xiaoyu.im.datamodel;

import androidx.annotation.StringDef;

import com.netease.nimlib.sdk.msg.constant.SessionTypeEnum;

import java.util.HashMap;
import java.util.Map;

public class ConversationType {

    public static final String UNKNOWN = "UNKNOWN";
    public static final String SINGLE = "SINGLE";
    public static final String GROUP = "GROUP";

    @StringDef({UNKNOWN, SINGLE, GROUP})
    public @interface ConversationStringTypeDef {
    }

    private static final Map<String, Integer> MAP = new HashMap<>();

    public static SessionTypeEnum toNimSessionType(String type) {
        if (type.equals(ConversationType.SINGLE)) {
            return SessionTypeEnum.P2P;
        }
        if (type.equals(ConversationType.GROUP)) {
            return SessionTypeEnum.Team;
        }
        return SessionTypeEnum.None;
    }

    @ConversationStringTypeDef
    public static String fromNimSessionType(SessionTypeEnum sessionType) {
        if (sessionType == SessionTypeEnum.P2P) {
            return SINGLE;
        }
        if (sessionType == SessionTypeEnum.Team) {
            return GROUP;
        }
        return UNKNOWN;
    }
}
